import request from '@/axios'
import type { CurdData } from './types'

export const getListApi = (params: any) => {
  return request.get({ url: '/admin/supplier/seller', params })
}

export const getGoodsListApi = (params: any) => {
  return request.get({ url: '/admin/supplier/product', params })
}

export const delListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.delete({ url: '/admin/supplier/seller', data: { ids } })
}

export const getInfoApi = (id: string): Promise<IResponse<CurdData>> => {
  return request.get({ url: '/admin/supplier/seller/' + id })
}

export const getGoodsInfoApi = (id: string): Promise<IResponse<CurdData>> => {
  return request.get({ url: '/admin/supplier/product/' + id })
}

export const getEnumApi = (params?: any) => {
  return request.get({ url: '/admin/supplier/seller/resource', params })
}

export const getGoodsEnumApi = (params?: any) => {
  return request.get({ url: '/admin/supplier/product/resource', params })
}

export const saveDataApi = (data: Partial<CurdData>): Promise<IResponse> => {
  if (data.id) {
    return request.put({ url: '/admin/supplier/seller', data })
  } else {
    return request.post({ url: '/admin/supplier/seller', data })
  }
}

export const saveProductDataApi = (data: Partial<CurdData>): Promise<IResponse> => {
  return request.put({ url: '/admin/supplier/product', data })
}

export const changeStatusApi = (data) => {
  return request.put({ url: '/admin/supplier/product/status', data })
}
